<?= $this->Html->script('admin-taste') ?>

<h1>
    Ukusi
    <span class="actions">
        <?= $this->Html->link('dodaj', 'javascript:void(0)', array(
            'onclick' => "addTasteGroup()",
            'title'   => 'Dodaj grupu',
            'class'   => 'add',
            'id'      => 'add-taste-group-btn'
        )) ?>
        <span id="add-taste-group" style="display:none">
            <input type="text">
            <a href="javascript:void(0)" class="action save" title="Sačuvaj">save</a>
            <a href="javascript:void(0)" class="action cancel" title="Poništi">cancel</a>
        </span>
    </span>
</h1>
<div class="accordion" id="taste-accordion">
    <? foreach ($groups as $id=>$name): ?>
    <h2 class="taste-group-<?= $id ?>" data-id="<?= $id ?>" data-name="<?= $name ?>">
        <span class="label"><?= $name ?></span>
        <span class="actions">
            <?= $this->Html->link('dodaj', 'javascript:void(0)', array(
                'onclick' => "addTaste({$id})",
                'title'   => 'Dodaj ukus',
                'class'   => 'add'
            )) ?>
            <?= $this->Html->link('izmeni', 'javascript:void(0)', array(
                'onclick' => "editTasteGroup({$id}, '{$name}')",
                'title'   => 'Izmeni grupu',
                'class'   => 'edit'
            )) ?>
            <?= $this->Html->link('obriši', 'javascript:void(0)', array(
                'onclick' => "remoteDelete('/admin_ukusi/delete_group/{$id}', {$id}, tasteGroupDeleted)",
                'class'   => 'delete',
                'title'   => 'Obriši grupu'
            )) ?>
        </span>
    </h2>
    <div class="taste-group-<?= $id ?>">
        <? $t = @$tastes[$name]; $t = empty($t) ? array() : $t ?>
        <ul class="admin-list-image">
            <? foreach ($t as $taste): ?>
            <? $tasteId = $taste['Taste']['id'] ?>
            <li>
                <h2><?= $taste['Taste']['name'] ?></h2>
                <?= $this->Html->image('ukusi/'.$taste['Taste']['image'].'?h=150') ?>
                
                <div class="actions">
                    <?= $this->Html->link('izmeni', 'javascript:void(0)', array(
                        'onclick' => "editTaste({$tasteId})",
                        'title'   => 'Izmeni ukus',
                        'class'   => 'edit'
                    )) ?>
                    <?= $this->Html->link('obriši', 'javascript:void(0)', array(
                        'onclick' => "remoteDelete('/admin_ukusi/delete/{$tasteId}', '{$tasteId}', tasteDeleted)",
                        'class'   => 'delete',
                        'title'   => 'Obriši ukus'
                    )) ?>
                </div>
            </li>
            <? endforeach ?>
        </ul>
    </div>
    <? endforeach ?>
</div>